<html>
  <head>
    <meta charset="UTF-8" />
    <title>Lesson10 - React第十课之状态提升</title>
  </head>
  <body>
    <div id="app"></div>

    
    <script src="../lib/react.development.js"></script>
    <script src="../lib/react-dom.development.js"></script>
    <script src="../lib/babel.min.js"></script>
    <script type="text/babel">
      const appDom = document.getElementById('app');
      
      function Age(props) {
        if (props.age < 18) {
          return <p>未成年～</p>
        } else {
          return <p>已成年～</p>
        }
      }

      class App extends React.Component {
        constructor(props) {
          super(props);
          this.state = {
            age: 0
          }
        }

        handleChange = (e) => {
          this.setState({
            age: e.target.value
          });
        }
        render() {
          return (
            <div>
              <input type='number' min="0" max="150"
                value={this.state.age} onChange={this.handleChange} />
              <input type='number' min="0" max="150"
                value={this.state.age*2/5} onChange={this.handleChange} />
              <Age age={this.state.age} />
            </div>
          )
        }
      }
      ReactDOM.render(<App />, appDom);
    </script>
  </body>
</html>